<?php
/*公共模块
 * 反馈
 * 系统更新
 * 成为分销
 * */
class PublicAction extends Action{
	public function feedback(){
		$feedbacd = M("Feedback");
		$feedbacd->feedbacktype = 1;//由软件传过来默认未1
		$feedbacd->feedback = trim($_POST["feedbacd"]);
		$feedbacd->uid = trim($_POST["uid"]);
		$feedbacd->ctime = time();
		if ($feedbacd->add()){
			$result=["code"=>"success"];
			header("Content-Type: text/json");
			die(json_encode($result));
		}else {
			$result=["code"=>"wrong"];
			header("Content-Type: text/json");
			die(json_encode($result));
		}
	}
	
	public function upgrade(){
		$type=$_POST["type"];
		if($type == "iphone"){
			$versionInfo = array(
					'version' => '1.0.0',
					'upgrade_tips' => '有最新的版本哦，亲快下载吧~',
					'download_url' => '',
					'must_upgrade' => 1,
			);
		} elseif($type=="android") {
			$versionInfo = array(
					'version' => '1.0.6',
					'upgrade_tips' => '有最新的版本哦，亲快下载吧~',
					'download_url' => 'http://yjkang.vba8.com/data/upload/YiJiKang1.0.6.apk',
					'must_upgrade' => 1,
			);
		}
		$result['code'] = "success";
		$result['data'] = $versionInfo;
		
		header("Content-Type: text/json");
		die(json_encode($result));
	}
	public function applySaler(){
		$sale = M("Saler");
		$sale->uid = trim($_POST["uid"]);
		$sale->applytime = time();
		if ($sale->add()){
			$value = ["code" =>"success"];
			header("Content-Type: text/json");
			die(json_encode($value));
		}else{
			$value = ["code" =>"wrong"];
			header("Content-Type: text/json");
			die(json_encode($value));
		}
	}
	//是否已经提交申请
	public function is_applySale(){
		$sale = M("Saler");
		$uid = trim($_REQUEST["uid"]);
		$data = $sale->where("uid = $uid")->find();
		if(isset($data["id"])){
			$value = ["code" =>1];
		}else{
			$value = ["code" =>0];
		}
		
		header("Content-Type: text/json");
		die(json_encode($value));
	}
	
	public function showCommunity(){
		$this->display("communityUserAgreement");
	}
	

}